@extends('home.layout.base')
@section('title', '商品列表页')
@section('pluginstyle')
<script src="{{ asset('/dist/home/js/1102.js') }}"></script>
<link rel="stylesheet" href="{{ asset('/dist/home/css/search.css') }}" />
<script>var _isindex = 0;</script>
@endsection
@section('content')
<div class="product-list"> 
    <div class="search-box"> 
        <div class="search-nav"> 
            <span class="default_path">
                <a href="{{ url('/') }}">首页</a><i>&gt;</i>
                <a href="{{ url('/list') }}">全部搜索结果</a><i>&gt;</i>
            </span> 
            <div class="breadcrumbs_box">
                @foreach($crumb as $c)
                <a href="{{ url('/list', [$c->id]) }}"><span class="sw_box"> {{ $c->cate_name }}</span> </a><i>&gt;</i>
                @endforeach
            </div> 
            <span>{{ $cateName }}</span> 
        </div> 
    </div> 
    <div class="filter-box" style="display: block;">
        @if(count($cateInfo)>0)
        <div class="filter js-cates"> 
            <div class="hint">
                分类:
            </div> 
            <div class="option_box unspread"> 
                @foreach($cateInfo as $cate)
                <a class="" href="{{ url('/list', ['id'=>$cate->id]) }}" title="{{ $cate->cate_name }}">{{ $cate->cate_name }}</a> 
                @endforeach
                <div class="find_more"> 
                    <span class="spread_icon">
                        <img class="up" src="{{ asset('/dist/home/images/t015f4bcc45a14cddc3.png') }}" />
                        <img class="down" src="{{ asset('/dist/home/images/t01b76f029538d8f9df.png') }}" />
                    </span> 
                    <span class="find_txt">查看更多</span>
                </div> 
            </div> 
        </div>
        @endif
        <div class="filter js-sort last"> 
            <span class="hint">排序: </span> 
            <a class="active" href="{{ url() }}">默认</a> 
            <a class="" href="">价格</a> 
            <span class="filter-chkbox">
                <label> <input type="checkbox" id="is-stock"/> 仅看有货产品 </label>
            </span> 
        </div>
    </div> 
    <div class="list-box"> 
        <div class="listwrap"> 
            <div class="list-container">
                <ul class="list">
                    @foreach($goodsList as $goods)
                    <li class="list-item"> 
                        <dl class="desc"> 
                            <dt class="pic"> 
                            <a href="{{ url('/item', ['id'=>$goods->id]) }}">
                                <img class="lazy" data-size="180_180_" src="{{ $goods->goods_thumb }}" alt="{{ $goods->goods_name }}" />
                            </a> 
                            </dt> 
                            <dd class="cont"> 
                                <a href="{{ url('/item', [$goods->id]) }}">
                                    <span class="title">{{ $goods->goods_name . $goods->attr->attr_type }}</span>
                                    <span class="price"> {{ $goods->goods_price }}元 </span> 
                                </a> 
                            </dd> 
                            <dd class="btns">
                                @if($goods->goods_num)
                                <a class="add-cart" onclick="addCart(this)" href="javascript:void(0);" data-id="{{ $goods->id }}" data-aid="{{ $goods->attr->id }}"><em>加入购物车</em></a>
                                @else
                                <a href="javascript:void(0);" class="gray">已售罄</a> 
                                @endif
                            </dd> 
                        </dl>
                    </li> 
                    @endforeach
                </ul>
            </div> 
            <div class="layer flexbox" style="display: none;">
                加载中...... 
            </div> 
        </div> 
        <ul id="kkpager" class="pagelist">
            <div>
                {!! $goodsList->render() !!}
            </div>
            <div style="clear:both;"></div>
        </ul> 
    </div>
    <div class="list-item clone-item js-clone-item" style="height: 356px; top: 440.091px; left: 53px; display: none;"></div>
</div>
@endsection
@section('pluginscript')
<script src="{{ asset('/dist/home/js/jquery.easing.1.3.js') }}"></script>
<script type="text/javascript">
$(function(){
    var e = $('.js-clone-item');
    $('.list-container').delegate('.list-item', 'mouseenter', function(){
        var t = this,
            n = $(t).offset();
        e.stop(!0).css({
            height:"356px",
            top: n.top + "px",
            left: n.left + "px"
        }).html($(t).html()).show().animate({
            top: n.top - 5 + "px"
        }, 'fast'), e.on('mouseleave', function(){
            e.stop(!0).hide().html('');
        }), e.on('hover', function(){}, function(){
            e.stop(!0).hide().html("");
        });
    });
});
function addCart(obj){
    var that = $(obj);
    var data = {};
    data.goods_id = that.attr('data-id');
    data.attr_id = that.attr('data-aid');
    data.cart_num = 1;
    
    $.get("{{ url('/shopcar/add') }}", data, function(msg){
        if(msg.status == '1'){
            qikoo.dialog.alert("加入购物车成功!");
        } else if(msg.status == '-1') {
            qikoo.dialog.alert("请先登录!");
        } else {
            qikoo.dialog.alert("加入购物车失败!");
        }
    });
    return false;
}
</script>
@endsection